package com.zts.modules.sys.mapper;

import com.zts.base.data.CrudMapper;
import com.zts.modules.sys.entity.User;

import com.zts.modules.sys.entity.UserGroupRelation;
import com.zts.modules.sys.entity.UserGroups;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;

import java.util.List;


/**
 * Created by Zhangkh on 2017/6/2.
 */
public interface UserMapper extends CrudMapper<User> {

    @Override
    @SelectProvider(type = UserSqlProvider.class, method = "get")
    User get(Long id);

    @Override
    @SelectProvider(type = UserSqlProvider.class, method = "getByEntity")
    List<User> getByEntity(User user);

    @Override
    @SelectProvider(type = UserSqlProvider.class, method = "getList")
    List<User> getList(User user, RowBounds rowBounds);

    @Override
    @UpdateProvider(type = UserSqlProvider.class, method = "update")
    int update(User user);

    @Override
    @InsertProvider(type = UserSqlProvider.class, method = "insert")
    @SelectKey(statement = "SELECT CURRVAL('seq_user_group_id')", keyProperty = "id", before = false, resultType = Long.class)
    int insert(User user);

    @Override
    @DeleteProvider(type = UserSqlProvider.class, method = "delete")
    int delete(User user);


    @SelectProvider(type = UserSqlProvider.class, method = "getByLoginKey")
    User getByLoginKey(String loginKey);

    @UpdateProvider(type = UserSqlProvider.class, method = "updatePassword")
    int updatePassword(User user);

    @SelectProvider(type = UserSqlProvider.class, method = "getUserGroup")
    List<UserGroupRelation> getUserGroup();

    @SelectProvider(type = UserSqlProvider.class, method = "getGroups")
    List<UserGroups> getGroups(String userIds);
}
